<?php
/*
+--------------------------------------------------------------------------
|   AffiliStore 2
|   ========================================
|   Web: http://www.affilistore.com
|   Email: admin (at) affilistore (dot) com
|	License Type: AffiliStore 2 is NOT open source software and limitations apply 
|   Licence Info: Visit AffiliStore website and click on 'Licence'
+--------------------------------------------------------------------------
*/
if (eregi(".inc.php",$HTTP_SERVER_VARS['PHP_SELF']) || eregi(".inc.php",$_SERVER['PHP_SELF'])) {
	echo "<html>\r\n<head>\r\n<title>Forbidden 403</title>\r\n</head>\r\n<body><h3>Forbidden 403</h3>\r\nThe document you are requesting is forbidden.\r\n</body>\r\n</html>";
	exit;
}

$box_content = new XTemplate ("skins/".$configSkin['value']."/styleTemplates/accountForgotPassword.tpl");
include_once 'includes/models/Account.php';

if(isset($_POST['email'])) {
	$accountObj = new Account();
	if ($currAccount = $accountObj->getByEmail($_POST['email']))
	{
		$mailTo = $_POST['email'];
		$mailSubject = "Password Recovery from Shopnmatch.com!";
		$mailBody = 'Hi '.$currAccount['accUsername'].', this is your new password which has just been auto-generated: '.substr($currAccount['accPassword'],0,8).'. Thanks for participating in shopnmatch.com.';
		mail($mailTo, $mailSubject, $mailBody);
		$editAccount['accPassword'] = md5(substr($currAccount['accPassword'],0,8));
		$accountObj->edit($editAccount,$currAccount['accUsername']);
		$box_content->assign("EMAIL",$currAccount['accContactEmail']);
		$box_content->parse('page.success');
	}
	else 
	{
		$box_content->parse('page.error');
	}
}
			
$box_content->assign("SKIN",$configSkin['value']);
$box_content->parse('page');
$box_content =  $box_content->text('page');
?>